import {createSlice,createAsyncThunk} from '@reduxjs/toolkit'
import {movieRequest} from '../../api'



//异步action
export const getMovieAction = createAsyncThunk('movie/getMovieList',async()=>{
     const result = await movieRequest()
     return result.data.data.list
})

const movieSlice = createSlice({
    name:'movie',
    initialState:{
        movieList:[]
    },
    reducers:{

    },
    extraReducers:{
        [getMovieAction.fulfilled](prevState,action){
            prevState.movieList = action.payload
        }
    }
})
export default movieSlice.reducer